Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to pnpm #3889

Merged
merged 24 commits into from
Sep 6, 2023
Merged

Migrate to pnpm #3889

merged 24 commits into from
Sep 6, 2023

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Sep 2, 2023

What this PR solves / how to test:
This is a big PR, but it's mostly because of the shift from npm's package-lock.json to the pnpm system. The rest of the PR deals with "phantom" dependencies that various parts of the codebase had—making sure those relationships were spelled out more explicitly.

Is pnpm worth it, you might ask? I think so. Beyond the raw speed improvements (hello 11s package install times in CI!), it also provides much better dependency isolation, which is starting to become a major problem for us as a large-ish monorepo. An upcoming PR relies on using a different version of React (18) than that used in Wrangler (17), which was tricky (read, "I gave up and switched to pnpm instead") to get working with the npm workspaces install algorithm (React itself was correctly hoisted to the package scope, but other dependencies weren't, leading to components from packages importing React 17 (from Wrangler), not React 18 (from the new package) as they should have done). pnpm provides a lot more customisability around hoisting, and also has better defaults (hoisting dependencies to the package scope by default).

This should change nothing for consumers of the Wrangler package (it'll still be usable from npm, yarn, and pnpm, as it is currently), but it'll change the workflow for contributors to Wrangler, who will need to switch to using pnpm for all installs. To that end, I've made updates to the README to use pnpm commands (and to specifically call out how to install pnpm for those who might not already have it installed).

In lieu of updating the wranglerjs-compat-webpack-plugin package to work with pnpm, the package has been removed. After team discussion, this package will be deprecated, but the source will continue to be available in the git history, or on the v2-maintenance branch

Author has included the following, where applicable:

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@changeset-bot
Copy link

changeset-bot bot commented Sep 2, 2023

⚠️ No Changeset found

Latest commit: bd3fb3f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@penalosa penalosa added the e2e Run e2e tests on a PR label Sep 2, 2023
@codecov
Copy link

codecov bot commented Sep 2, 2023

Codecov Report

Merging #3889 (bd3fb3f) into main (c3684e7) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3889      +/-   ##
==========================================
+ Coverage   75.12%   75.14%   +0.01%     
==========================================
  Files         195      195              
  Lines       11482    11485       +3     
  Branches     3033     3034       +1     
==========================================
+ Hits         8626     8630       +4     
+ Misses       2856     2855       -1     
Files Changed Coverage Δ
packages/wrangler/src/init.ts 92.69% <100.00%> (-0.46%) ⬇️

... and 2 files with indirect coverage changes

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6098052926/npm-package-wrangler-3889

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6098052926/npm-package-wrangler-3889

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6098052926/npm-package-wrangler-3889 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6098052926/npm-package-cloudflare-pages-shared-3889

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare 3.20230904.0 3.20230904.0
workerd 1.20230904.0 1.20230904.0
workerd --version 1.20230904.0 2023-09-04

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@penalosa penalosa marked this pull request as ready for review September 2, 2023 02:18
@penalosa penalosa requested review from a team as code owners September 2, 2023 02:18
.github/extract-runtime-versions.mjs Outdated Show resolved Hide resolved
.github/extract-runtime-versions.mjs Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
fixtures/external-durable-objects-app/package.json Outdated Show resolved Hide resolved
patches/[email protected] Outdated Show resolved Hide resolved
@JacobMGEvans
Copy link
Contributor

JacobMGEvans commented Sep 4, 2023

If you didn't do it, I was going to. It works better for Monorepo's and has other benefits!

Looks like Windows making things difficult 😞

.npmrc Outdated Show resolved Hide resolved
Copy link
Member

@GregBrimble GregBrimble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the concept from Pages' perspective so you're not blocked on us :)

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that fixed the Windows test, I am excited to see this go in!!!

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me. Thanks for this @penalosa

fixtures/pages-functions-wasm-app/package.json Outdated Show resolved Hide resolved
packages/create-cloudflare/e2e-tests/pages.test.ts Outdated Show resolved Hide resolved
packages/pages-shared/package.json Show resolved Hide resolved
packages/wrangler/e2e/helpers/normalize.ts Show resolved Hide resolved
packages/wrangler/src/__tests__/package-manager.test.ts Outdated Show resolved Hide resolved
@jculvey
Copy link
Contributor

jculvey commented Sep 5, 2023

Overall this looks good to me, but there's a bit of an issue with the c3 e2e tests. This change causes tests to use pnpm when running c3 in e2e tests even when we'd like them to run with npm.

The package detection code here falls back to npm as the default, which will no longer be the case when this lands. This change should fix it.

@penalosa penalosa merged commit 0938e25 into main Sep 6, 2023
27 of 28 checks passed
@penalosa penalosa deleted the penalosa/migrate-to-pnpm branch September 6, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants